#include<iostream>
#include<queue>
#include<string>
using namespace std;
const int maxn=210;
int left1[maxn],right1[maxn];
bool exist[maxn]={false};
int N;

int main(){
    //freopen("in.txt","r",stdin);
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        string sl,sr;
        cin>>sl>>sr;
        if(sl=="-") left1[i]=-1;
        else left1[i]=stoi(sl);exist[left1[i]]=true;
        if(sr=="-") right1[i]=-1;
        else right1[i]=stoi(sr);exist[right1[i]]=true;
    }
    int root=0,cnt=0;
    int lastnode;
    while(root<N&&exist[root]==true){root++;}
    queue<int> que;
    while(!que.empty())que.pop();
    que.push(root);
    while(!que.empty()){
        int t=que.front();que.pop();
        if(t==-1){
            if(cnt==N)printf("YES %d",lastnode);
            else printf("NO %d",root);
            return 0;
        }
        else{
            cnt++;
            lastnode=t;
        }
        que.push(left1[t]);
        que.push(right1[t]);
    }
}
